package audi.a4.control.core;

import java.util.ArrayList;

public class Ecu1Packet extends AbstractAudiA4Packet {

	public Ecu1Packet(double timeStamp,AudiA4CanCode code, int ID,ArrayList<String> data) {
		super(timeStamp, code,ID, data);
	}

	@Override
	public boolean validate(AudiA4CanCode code) {
		return code == AudiA4CanCode.ECU_1;
	}

	@Override
	public void parse(int[] byteData) {
		int [] parsed = new int[8];
		parsed[0] = (byteData[1]<<8) | byteData[0];
		if(parsed[0]>32767)
			parsed[0] = 32767-parsed[0];
		parsed[1] = (byteData[3]<<8) | byteData[2];
		if(parsed[1]>32767)
			parsed[1] = 32767-parsed[1];
		parsed[2] = ((byteData[5]&0xf0)>>4);
		parsed[3] = ((byteData[5]&0x0f));
		parsed[4] = byteData[6];
		parsed[5] = ((byteData[7]&0x0f));
		parsed[6] = ((byteData[7]&0xf0)>>4);
		parsed[7] = byteData[4];
		setParsedData(parsed);
	}

}
